/**
 * 
 */
package com.zhmy.xmgl;



import com.zhmy.xmgl.ZHMY_PROJECT_MANAGE.ZhmySchedule;

import edu.emory.mathcs.backport.java.util.Arrays;

/**
 * <pre>
 * Title: 程序的中文名称
 * Description: 程序功能的描述
 * </pre>
 * @author Robert
 * @version 1.00.00
 * 
 */
/*
 * 修改历史
 * $log$
 */
public class PeopleList {

	/**
	 * 
	 */
	public PeopleList() {
		// TODO 自动生成的构造函数存根
	}
	
	public People[] getPeopleList(ZhmySchedule[] list) {
		
		String allName = "";
		
		int count = list.length;
		//System.out.println("count= "+count);
		for (int a = 0; a < count; a ++) {
			
			ZhmySchedule te = list[a];
		
			String tempHead = te.getScheduleHead()+",";
			String tempMember = te.getSchedultMember()+",";
			
			//System.out.println("head="+tempHead);
			//System.out.println("member="+tempMember);
			
			allName += (tempHead + tempMember);
		}
		
		//System.out.println("allName= "+allName);
	
		People[] pp = str2PeopleArray(allName);
//		for(int i = 0; i < pp.length; i++) {
//			System.out.println("pp="+pp[i].getName());
//		}
		
		return pp;
	}
	
	private People[] str2PeopleArray(String str) {
		String[] strArray = str.split(",");
		java.util.List<String> list1 = Arrays.asList(strArray);
		
		java.util.List<String> list2 = new java.util.ArrayList<String>();
		int count = list1.size();
		for (int a = 0; a < count; a ++) {
			String name = list1.get(a);
			if(name.equals("null")) continue;
			if(name.equals("")) continue;
			if (!list2.contains(name)) {
				list2.add(name);
			}
		}
		
		int peopleCount = list2.size();
		People people= null;
		People[] peopleArray = new People[peopleCount];
		for (int c = 0; c < peopleCount; c++) {
			people = new People();
			people.setName(list2.get(c));
			peopleArray[c] = people;
		}
		
		return peopleArray;
	}
	
	public void print(String str) {
		System.out.println("PeopleDb=============="+str);
	}

}
